package fi.iki.joker.mobilogger.util;

import android.app.Application;
import android.content.Context;
import fi.iki.joker.mobilogger.db.DBUtil;
import fi.iki.joker.mobilogger.db.SettingBean;

public class SettingHelper {

	private static DBUtil db = null;
	
	
	/**
	 * Get a named setting value. If such value does not exits, then
	 * a runtime exception is thrown.
	 * @param name
	 * @return
	 */
	
	public static String getSettingValue(Context c, String name) {
		if(db == null) {
			db = new DBUtil();
		}
		SettingBean sb = null;
		sb = db.getSettingBeanByName(c,name);
		if(sb != null && name != null) {
			return sb.getSettingvalue();
		} else {
			throw new IllegalArgumentException("The named setting "+name+" is not defined (or found).");
		}
	}
	
}
